<?php
namespace app\index\model;

use think\Model;

class Classes extends Model{
    public function classlist(){
        $data =  $this->select();
        return $data;
    }

    public function newclass(){
        $data = $this->limit(1)->order('Id desc') ->select();
        return $data;
    }

    public function addclass($Name){
        $Data = [
            "Name" => $Name,
        ];
        return $this->insert($Data);
    }

    public function coscla($id){
        $data= $this->alias('cla')
                    ->join('cc c','cla.Id = c.class_Id')
                    ->join('course cos','c.course_Id = cos.Id')
                    ->where('cos.Id',$id)
                    ->select();
        return $data;
    }

    public function stucoscla($userId,$courseId,$classId){
        $data= $this->alias('cla')
                    ->join('ss','cla.Id = ss.class_Id')
                    ->join('sc s','ss.student_Id = s.S_Id')
                    ->where('s.S_Id',$userId)
                    ->where('s.C_Id',$courseId)
                    ->where('ss.class_Id',$classId)
                    ->select();
        return $data;
    }
}